﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entity.Framework;

namespace Business.Operations
{
    public class SehirOperation
    {
        private static HPDMASEntities db = new HPDMASEntities();

        public SehirOperation()
        {

        }

        public static List<Sehir> SehirGetAll()
        {
            var sehirListesi = db.Sehir.ToList();
            return sehirListesi;
        }

        public static Sehir SehirGetBySehirId(int sehirId)
        {
            var sehir = (from c in db.Sehir where c.SehirID == sehirId select c).First();
            return sehir;
        }

        /// <summary>
        /// Diger Fonksiyonlar
        /// </summary>
        /// <returns></returns>
        public static List<string> SehirAdiGetAll()
        {
            var sehirAdiListesi = (from s in db.Sehir orderby s.SehirAdi ascending select s.SehirAdi).ToList();
            return sehirAdiListesi;
        }

        public static Sehir SehirGetBySehirAdi(string sehirAdi)
        {
            var sehir = (from c in db.Sehir where c.SehirAdi == sehirAdi select c).First();
            return sehir;
        }

        public static int SehirIdGetBySehirAdi(string sehirAdi)
        {
            var sehirId = db.Sehir.
                Where(c => c.SehirAdi == sehirAdi).
                Select(c => c.SehirID).FirstOrDefault();
            return sehirId;
        }

        public static string SehirAdiGetBySehirId(int sehirId)
        {
            var sA = (from c in db.Sehir where c.SehirID == sehirId select c.SehirAdi).First();
            return sA;
        }

        public static string DogumYeriAdiGetByKullaniciId(int kullaniciId)
        {
            var sehirAdi = (from k in db.KullaniciNfs where k.KullaniciID == kullaniciId select k.Sehir.SehirAdi).First();
            return sehirAdi;
        }

        public static string KayitliOlduguIlAdiGetByKullaniciId(int kullaniciId)
        {
            var sehirAdi = (from k in db.KullaniciNfs where k.KullaniciID == kullaniciId select k.Sehir1.SehirAdi).First();
            return sehirAdi;
        }


    }
}
